using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.IO;

using Enterprise.Statistics.WindowsServices.Common.Log;
using Enterprise.Statistics.WindowsServices.DataTransferLibrary.Log;
using Enterprise.Statistics.WindowsServices.IITStatisticsTransferService30.Properties;
using Enterprise.Statistics.WindowsServices.DataTransferLibrary.BL.Flows;

namespace Enterprise.Statistics.WindowsServices.IITStatisticsTransferService30
{
    partial class IITStatisticsTransferService30 : ServiceBase
    {
        private ServiceTimer _serviceTimer;
        private PerformanceMonitor _performanceTimer;

        NLogController _nLogController;

        #region Constructors
         
        public IITStatisticsTransferService30()
        {
            InitializeComponent();

            try
            {
                Initialize();
            }
            catch (Exception ex)
            {
                NLogWriter.WriteLogger("Exception", null, null, ex);
                throw ex;
            }
        }

        #endregion

        #region Helper Methods

        private void Initialize()
        {
            _serviceTimer = new ServiceTimer(Settings.Default.DataFlowFileFolder);
            _performanceTimer = new PerformanceMonitor();
            _nLogController = new NLogController();
        }

        #endregion

        #region Events

        protected override void OnStart(string[] args)
        {
            try
            {
                _serviceTimer.Start();
                _performanceTimer.Start();
            }
            catch (Exception ex)
            {
                NLogWriter.WriteLogger("Exception", null, null, ex);
                throw ex;
            }
        }

        protected override void OnStop()
        {
            try
            {
                _serviceTimer.Stop();
                _performanceTimer.Stop();
            }
            catch (Exception ex)
            {
                NLogWriter.WriteLogger("Exception", null, null, ex);
                throw ex;
            }
        }

        #endregion
    }
}
